<include file="Public/header" />
<style>
.btngreen30{padding:4px 10px;}
</style>
    <div class="comm-top">
    	<include file="Customer/nav" act_nav="index"/>
        <div class="title-left"> 员工列表</div>
        <div class="title-right" style="top:8px;">
        <form method="get" action="{:U('index')}">
            <input name="keywords" class="textarea search_inp" placeholder="请输入关键词" type="text" value="{:I('get.keywords')}"/>
            <input value="搜索" class="btn btn-success search_btn" type="submit" />
        </form>
        </div>
    </div>
    <div class="list-table">
        <div class="wrapper">
            <table class="stable">
                <thead>
                    <tr>
                        <th>账号</th>
                        <th>昵称</th>
                        <th>创建时间</th>
                        <th>账号状态</th>
                        <th>密码修改</th>
                        <th>管理</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <foreach name="list" item="vo">
                        <tr>
                            <td>{$vo.username}</td>
                            <td>{$vo.nickname}</td>
                            <td>{:substr($vo['add_time'],0,10)}</td>
                            <if condition="$vo['status'] eq 1">
                                <td class="staTd" data-id="{$vo.id}"><span class="staAct">开放</span> | <span data-status="2">关闭</span></td>
                            <else />
                                <td class="staTd" data-id="{$vo.id}"><span data-status="1">开放</span> | <span class="staAct">关闭</span></td>
                            </if>
                            <td><span class="btngreen30" onclick="editp('{$vo.id}')">修改</span></td>
                            <td><span class="btngreen30" onclick="set_power('{$vo.id}')">分配权限</span></td>
                            <td><div class="btn-operate">
                                <a href="{:U('add',array('id'=>$vo['id']))}" title="修改"><i class="glyphicon glyphicon-edit"></i></a>
                                <a href="javascript:void(0);" onclick="delRow('{$vo.id}',this)" title="删除" id="delBtn{$vo.id}"><i class="glyphicon glyphicon-trash"></i></a>
                            </div></td>
                        </tr>
                    </foreach>
                </tbody>
            </table>
        </div>
    </div>
    <div class="page-list">{$page}</div>
    <include file="Public/dialog"/>
<script type="text/javascript">
$(function(){
    $('.staTd span').click(function(){
        if($(this).hasClass('staAct')) return;
        $.get("{:U('set_status')}",{id:$(this).parent().attr('data-id'),status:$(this).attr('data-status')},function(){
            location.reload();
        });
    });
});
//删除
function delRow(id,obj){
    if(confirm('确定要删除吗？')){
        $.post("{:U('delete_data')}",{id:id},function(res){
            if(res.status == 1){
                note_info(res.info,obj);
                setTimeout('location.reload()',1200);
            }else{
                note_info(res.info,obj,'warn');
            }
        },'json');
    }
}
//打开修改密码弹框
function editp(id){
	$.get("{:U('editp')}?id="+id,function(result){
		dialog(result,'修改密码',function(event){
		    var obj = event.target;
		    $.post("{:U('editp')}",$('#dataForm').serializeArray(),function(data){
		        if(data.status == '1'){
		        	note_info(data.info,obj);
		            setTimeout('location.reload()',1200);
		        }else{
		            note_info(data.info,obj,'warn');
		        }
		    });
		});
	});
}
//修改密码

function set_power(id){
	$.get("{:U('set_power')}?id="+id,function(result){
		dialog(result,'分配权限',function(event){
			var obj = event.target;
		    $.post("{:U('set_power')}",$('#dataForm').serializeArray(),function(data){
		        if(data.status == '1'){
		        	note_info(data.info,obj);
		            setTimeout('location.reload()',1200);
		        }else{
		            note_info(data.info,obj,'warn');
		        }
		    });
		});
	});
}
//验证为3-10位的密码
function isPassword(s){
    var patrn=/^[a-zA-Z0-9]{3,10}$/;  
    if (!patrn.exec(s)) return false
    return true
}
</script>
<include file="Public/footer" />